package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.GongYingShangType;
import com.gxa.service.shezhiservice.GongYingShangType46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
     * @Author x
     */
    @RestController
    @RequestMapping("/GongYingShangType")
    @Api(value = "供应商类别" , tags = "供应商数据接口API")
    @RequiresPermissions("供应商类别")
public class GongYinShangTypeController {
        @Autowired(required = false)
        public R r;
        @Autowired(required = false)
        public GongYingShangType46Service gongYingShangType46Service;
        @GetMapping("/selectAllGongYingShangTypeForPage")
        @ApiOperation(value = "查询所有供应商类别接口",notes = "提供页码和每页显示数",httpMethod = "get",response = R.class)
        @ApiImplicitParams({
                @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
                @ApiImplicitParam(name = "size",value = "每页显示数",required = true,dataType = "int",paramType = "query"),

        })
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public R selectAllGongYingShangTypeForPage(@RequestParam int page, @RequestParam int size)
        {
//            r.setCode(200);
//            r.setMsg("查询成功");
////            GongYingShangType gongYingShangType = new GongYingShangType();
////            gongYingShangType.setGongYingShangType("022");
////
////            gongYingShang.setGongYingShangType(gongYingShangType);
//            ArrayList<Object> list = new ArrayList<>();
//            list.add("jjj");
//            r.setData(list);
//            return r;
            return gongYingShangType46Service.selectAllGongYingShangTypeForPage( page , size );
        }

        @GetMapping("/selectGongYingShangTypeByType")
        @ApiOperation(value = "根据供应商类别查询",notes="提供供应商类别信息",httpMethod = "get",response = R.class)
        @ApiImplicitParams({
                @ApiImplicitParam(name="page",value="当前页码数",required = true,dataType = "int",paramType = "query"),
                @ApiImplicitParam(name="size",value="每页显示记录数",required = true,dataType = "int",paramType = "query"),
                @ApiImplicitParam(name="GongYingShangType",value = "供应商类别",dataType = "String",paramType = "query"),
        })
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public R selectGongYingShangTypeByType(@RequestParam int page,@RequestParam int size,String gongYingShangType)
        {
//            r.setCode(200);
//            r.setMsg("查询成功");
//            ArrayList<Object> list = new ArrayList<>();
//            GongYingShangType gongYingShangType = new GongYingShangType();
//            gongYingShangType.setGongYingShangType("66");
//            list.add(GongYingShangType);
//            r.setData(list);
//            return r;
            return gongYingShangType46Service.selectGongYingShangTypeByType(page ,size ,gongYingShangType);
        }
        @PostMapping("/deleteGongYingShangTypeById")
        @ApiOperation(value = "删除供应商类别接口",notes = "提供供应商类别id",httpMethod = "get",response = R.class)
        @ApiImplicitParams({
                @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int",paramType = "query")
        })
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public R deleteGongYingShangTypeById(@RequestParam int id)
        {
//            r.setCode(200);
//            r.setMsg("删除成功");
//            ArrayList<Object> list = new ArrayList<>();
//            GongYingShangType gongYingShangType = new GongYingShangType();
//            gongYingShangType.setId(55);
//            list.add(id);
//            r.setData(list);
//            return r;
            return gongYingShangType46Service.deleteGongYingShangTypeById(id);
        }
        @PostMapping("/insertGongYingShangType")
        @ApiOperation(value="新增供应商类别接口",notes="提供供应商类别信息",httpMethod = "post",response = R.class)
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public R insertGongYingShangType(@RequestBody GongYingShangType gongYingShang)
        {
//            r.setCode(200);
//            r.setMsg("插入成功");
//            ArrayList<Object> list = new ArrayList<>();
//            GongYingShangType gongYingShangType2 = new GongYingShangType();
//            gongYingShangType2.setGongYingShangType("66");
//            list.add(gongYingShangType2);
//            r.setData(list);
//            return r;
            return gongYingShangType46Service.insertGongYingShangType(gongYingShang);
        }
        @PostMapping("/updateGongYingShangTypeById")
        @ApiOperation(value="修改供应商类别信息接口",notes = "提供供应商类别信息",httpMethod = "post",response = R.class)
        @ApiResponses({
                @ApiResponse(code=200,message="请求成功"),
                @ApiResponse(code=404,message="找不到页面"),
                @ApiResponse(code=500,message="后台服务错误")
        })
        public R updateGongYingShangTypeById(@RequestBody GongYingShangType gongYingShang)
        {

//            r.setCode(200);
//            r.setMsg("修改成功！");
//            ArrayList<Object> list = new ArrayList<>();
//            GongYingShangType gongYingShangType3 = new GongYingShangType();
//            gongYingShangType3.setGongYingShangType("66");
//            list.add(gongYingShangType3);
//            r.setData(list);
//            return r;
            return gongYingShangType46Service.updateGongYingShangTypeById(gongYingShang);
        }

    }


